<template>
    <a-spin :spinning="confirmLoading">
      <j-form-container :disabled="false">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-row :gutter="48">
            <a-col :span="8" :hidden="true">
              <a-form-model-item label="流程名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bpmBizTitle" >
                <a-input :max-length="255" :disabled="formDisabled" v-model="model.bpmBizTitle" placeholder="请输入流程名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="formDisabled">
              <a-form-model-item label="合同编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="finalNo">
                <a-input :disabled="true" v-model="model.finalNo" placeholder="请输入合同编号"></a-input>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="8">
              <a-form-model-item label="合同名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htmc">
                <a-input :disabled="formDisabled" v-model="model.htmc" placeholder="请输入合同名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-if="model.htlx == '2'">
              <a-form-model-item label="费用类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="feeType">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="list"
                  v-model="model.feeType"
                  dictCode="fee_type"
                  placeholder="请选择费用类型"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-if="model.htlx == '2'">
              <a-form-model-item label="是否采购类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isCategoryType">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="radio"
                  v-model="model.isCategoryType"
                  dictCode="is_category_type"
                  placeholder="请选择是否采购类"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="formDisabled">
              <a-form-model-item label="申请时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
                <j-date :disabled="true" placeholder="请选择申请时间" v-model="model.createTime" style="width: 100%"/>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="8" v-show="formDisabled">
              <a-form-model-item label="申请人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createBy">
                <!-- <select-user-by-dep disabled :multi="false" v-model="model.proposer"/> -->
                <j-select-user-by-dep v-model="model.createBy" :multi="false" disabled></j-select-user-by-dep>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="formDisabled">
              <a-form-model-item label="申请部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sysOrgCode">
                <!-- <j-select-depart :disabled="true" v-model="model.proposerDeptId"/> -->
                <j-select-depart v-model="model.sysOrgCode" :trigger-change="true" disabled customReturnField="orgCode" :multi="true"></j-select-depart>
              </a-form-model-item>
            </a-col>
            <template v-if="model.htlx == '2'">
              <a-col :span="8">
                <a-form-model-item label="申请人所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="applyTeam">
                  <select-team-input
                    :disabled="formDisabled"
                    placeholder="请选择申请人所属团队"
                    v-model="model.applyTeam"
                    :tdlx="1" />
                </a-form-model-item>
              </a-col>
            </template>
            <a-col :span="8">
              <a-form-model-item label="合同类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htlx">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="list"
                  v-model="model.htlx"
                  dictCode="htlx_type"
                  placeholder="请选择合同类型"
                  @change="htlxChange"
                  :triggerChange="true"/>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="8">
              <a-form-model-item label="合同变更状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="htlx">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="list"
                  v-model="model.changeStatus"
                  dictCode="change_status"
                  placeholder="请选择合同变更状态"
                  @change="htlxChange"
                  :triggerChange="true"/>
              </a-form-model-item>
            </a-col>
            <!-- <a-col :span="8">
              <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmmc">
                <a-input :readOnly="true" v-model="model.xmmc_dictText" style="color: #1890FF;" @click.prevent="getProjectDetail(model.xmmc)"></a-input>
              </a-form-model-item>
            </a-col> -->
            <a-col :span="8" v-show="model.isCategoryType == '1'">
              <a-form-model-item label="采购类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="provisionType">
                <j-dict-select-tag type="list" dictCode="provision_type" :disabled="formDisabled" v-model="model.provisionType" placeholder="请选择采购类型" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="model.provisionType == '1'" >
              <a-form-model-item label="关联单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="calibrationId">
                <a-input
                  v-if="formDisabled"
                  readOnly
                  @click.prevent="goPurchaseCalibrationDetail(model)"
                  v-model="model.calibrationNo"
                  style="color: #1890FF; cursor: pointer;"
                  placeholder="请关联定标结果确认单"></a-input>
                <select-purchase-calibration-input v-else :disabled="formDisabled" placeholder="请关联定标结果确认单" v-model="model.calibrationId" :projectId="model.xmmc" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="model.provisionType == '2'" >
              <a-form-model-item label="关联单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="purchaseApplyId">
                <a-input
                  v-if="formDisabled"
                  readOnly
                  @click.prevent="goPurchaseApplyDetail(model)"
                  v-model="model.purchaseNo"
                  style="color: #1890FF; cursor: pointer;"
                  placeholder="请关联采购申请单"></a-input>
                <select-purchase-apply-form-contract-input v-else :disabled="formDisabled" placeholder="请关联采购申请单" v-model="model.purchaseApplyId" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="model.provisionType == '3'" >
              <a-form-model-item label="关联单据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="invitationId">
                <a-input
                  v-if="formDisabled"
                  readOnly
                  @click.prevent="goInvitationDetail(model)"
                  v-model="model.invitationNo"
                  style="color: #1890FF; cursor: pointer;"
                  placeholder="请关联采购申请单"></a-input>
                <SelectPurchasingRequisitionInput v-else v-model="model.invitationId" placeholder="请关联招标采购申请单" :disabled="formDisabled" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8" style="display:none">
              <a-form-model-item label="项目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmbh">
                <a-input :disabled="true" v-model="model.xmbh" placeholder="请输入项目编号"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <!-- 迭代16.7 选择经营费用的时候，单据中经营团队改成费用所属团队，弹窗团队选择； -->
              <a-form-model-item v-if="model.htlx == '2' && model.feeType=='2'" label="费用所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jytd">
                <select-team-input
                   @back="changeVal"
                  :disabled="formDisabled"
                  v-model="model.jytd"
                  :tdlx="1"/>
              </a-form-model-item>
              <a-form-model-item v-else label="经营团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jytd">
                <select-team-input
                  @back="changeVal"
                  :disabled="formDisabled"
                  v-model="model.jytd"
                  :tdlx="1"/>
              </a-form-model-item>
            </a-col>
            <!-- <a-col :span="8"> 
                <a-form-model-item  label="经营公司" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessCompanyId">
                <select-Company-input :disabled="formDisabled" placeholder="请选择经营公司" v-model="model.businessCompanyId" disabled />
              </a-form-model-item>
              </a-col> -->
            <a-col :span="8">
              <a-form-model-item label="业绩归属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yjgsnd">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="list"
                  v-model="model.yjgsnd"
                  dictCode="yjgsnd"
                  placeholder="请选择业绩归属年度"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="签订单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qddw">
                <select-Company-input :disabled="formDisabled" v-model="model.qddw" placeholder="请选择签订单位"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目承接人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmcjr">
                <select-user-by-dep :disabled="formDisabled" :multi="false" v-model="model.xmcjr"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="业主单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yzdw">
                <select-customer-input
                  :disabled="formDisabled"
                  v-model="model.yzdw"
                  commercialType="1"
                  @change="yzdwChange"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxr">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="list"
                  v-model="model.lxr"
                  :dictCode="cust_lxr"
                  placeholder="请选择联系人"
                  @change="lxrChange"
                  :triggerChange="true"/>
  
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="联系方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxfs">
                <a-input :disabled="formDisabled" v-model="model.lxfs" placeholder="请输入联系方式"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="签订日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qdrq">
                <j-date :disabled="formDisabled" placeholder="请选择签订日期" v-model="model.qdrq" style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <!-- <a-col :span="8">
              <a-form-model-item label="履约保证金（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bail">
                <a-input disabled placeholder="请选择签订日期" v-model="model.bail" :defaultValue="0" />
              </a-form-model-item>
            </a-col> -->
            <a-col v-if="model.feeType === '1'" :span="8">
              <a-form-model-item  label="任务编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskId">
                <SelectTaskFileInput
                      :disabled="formDisabled"
                      v-model="model.taskId"
                    />
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-show="model.htlx==1">
              <a-form-model-item
                label="分配方式"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="distributionMethod">
  
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="list"
                  v-model="model.distributionMethod"
                  dictCode="distribution_method"
                  placeholder="请选择分配方式"/>
  
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="是否用印" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfyz">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="radio"
                  v-model="model.sfyz"
                  dictCode="yn"
                  placeholder="请选择是否用印"/>
              </a-form-model-item>
            </a-col>
            <template v-if="model.sfyz == '0' && model.htlx == '1'">
              <a-col :span="8">
                <a-form-model-item label="无正式合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noFormalContract">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="radio"
                    v-model="model.noFormalContract"
                    dictCode="YES_OR_NO"
                    placeholder="请选择无正式合同"/>
                </a-form-model-item>
              </a-col>
            </template>
            <a-col :span="8" v-if="isUseChapter">
              <a-form-model-item label="用印类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="signSealWay">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="select"
                  v-model="model.signSealWay"
                  dictCode="seal_way"
                  placeholder="请选择用印类型"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item v-if="isUseChapter" label="印章类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yzlx">
                <j-multi-select-tag
                  :disabled="formDisabled"
                  type="select"
                  v-model="model.yzlx"
                  dictCode="yzlx_type"
                  placeholder="请选择印章类型"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item v-if="isUseChapter" label="用印份数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yyfs">
                <a-input-number
                  :disabled="formDisabled"
                  :max="99999999"
                  :min="0"
                  v-model="model.yyfs"
                  placeholder="请输入用印份数"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <!--迭代16.8 增加是否存档字段 -->
              <a-form-model-item label="是否存档" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfcd">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="radio"
                  v-model="model.sfcd"
                  dictCode="yes_no"
                  placeholder="请选择是否存档"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" v-if="model.sfcd==='1'">
              <!--迭代16.8 增加是否存档字段 -->
              <a-form-model-item label="合同存档份数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cdfs">
                <a-input-number
                  :disabled="formDisabled"
                  :max="99999999"
                  :min="0"
                  v-model="model.cdfs"
                  placeholder="请输入合同存档份数"
                  style="width: 100%"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="24" v-if="!isUseChapter">
              <a-form-model-item label="合同原件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="masterCopy">
                <j-upload v-if="!formDisabled" :disabled="formDisabled" v-model="model.masterCopy"></j-upload>
                <a-button v-else icon="download" :disabled="isRequesting" @click="viewFileOne(model.masterCopy)">文件列表</a-button>
              </a-form-model-item>
            </a-col>
            <a-col :span="8" :hidden="model.htlx == 1">
              <a-form-model-item label="关联收款合同" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="glskht">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="radio"
                  v-model="model.glskht"
                  dictCode="yn"
                  placeholder="请选择关联收款合同"
                  @change="glskhtChange"
                  :triggerChange="true"/>
  
              </a-form-model-item>
            </a-col>
            <template v-if="glhtFlag">
              <a-col :span="8">
                <a-form-model-item label="收款合同名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skhtmc">
                  <!--<a-input :disabled=formDisabled v-model="model.skhtmc" placeholder="请输入收款合同名称"  ></a-input>
                  <select-contract-input
                    :disabled="formDisabled"
                    v-model="model.skhtmc"/>-->
                  <select-contract-manager-input
                    :muitFlag="true"
                    :disabled="formDisabled"
                    v-model="model.skhtmc"
                  />
                </a-form-model-item>
              </a-col>
              <!--            <a-col :span="8">-->
              <!--              <a-form-model-item label="甲方" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jf">-->
              <!--                <select-Company-input :disabled="formDisabled" v-model="model.jf" placeholder="请选择甲方"/>-->
              <!--              </a-form-model-item>-->
              <!--            </a-col>-->
              <!--            <a-col :span="8">-->
              <!--              <a-form-model-item label="乙方" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yf">-->
              <!--                <select-customer-input  :disabled="formDisabled" v-model="model.yf" commercialType="2"/>-->
              <!--              </a-form-model-item>-->
              <!--            </a-col>-->
              <a-col :span="8">
                <a-form-model-item label="收款合同额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skhte">
                  <a-input-number
                    :disabled="formDisabled"
                    :max="99999999"
                    :min="0"
                    v-model="model.skhte"
                    placeholder="请输入收款合同额"
                    style="width: 100%"
                    @blur="convertMoney1"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="收款合同额大写" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skhtedx">
                  <a-input :disabled="true" v-model="model.skhtedx" placeholder="请输入收款合同额大写"></a-input>
                </a-form-model-item>
              </a-col>
            </template>
  
            <a-col :span="8">
              <a-form-model-item label="本次合同额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bchte">
                <a-input-number
                  :disabled="formDisabled"
                  :max="99999999"
                  :min="0"
                  v-model="model.bchte"
                  placeholder="请输入本次合同额"
                  style="width: 100%"
                  @blur="convertMoney2"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="本次合同额大写" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bchtedx">
                <a-input :disabled="true" v-model="model.bchtedx" placeholder="请输入本次合同额大写"></a-input>
              </a-form-model-item>
            </a-col>
            <template v-if="model.htlx == '1'">
              <a-col :span="8">
                <a-form-model-item label="经营绩效(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessPerformance">
                  <a-input-number
                    :precision="2"
                    :disabled="formDisabled"
                    :max="99999999"
                    :min="0"
                    v-model="model.businessPerformance"
                    placeholder="请输入经营绩效"
                    style="width: 100%"/>
                </a-form-model-item>
              </a-col>
            </template>
            <a-col :span="8">
              <a-form-item label="服务期限">
                <a-range-picker
                  :disabled="formDisabled"
                  :allowClear="false"
                  v-model="createTime"
                  style="width: 100%"
                  @change="createTimeChange"/>
              </a-form-item>
            </a-col>
            <!-- <a-col :span="8">
              <a-form-model-item label="服务期限" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fwqx">
                <j-date :disabled="formDisabled" placeholder="请选择服务期限" v-model="model.fwqx" style="width: 100%"/>
              </a-form-model-item>
            </a-col> -->
            <!--<a-col :span="8">
              <a-form-model-item label="合同签订状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
                <a-input :disabled=formDisabled v-model="model.status" placeholder="请输入合同签订状态"  ></a-input>
              </a-form-model-item>
            </a-col>-->
  
            <!-- <a-col :span="8">
              <a-form-model-item label="是否涉及多方信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="involveMultiple">
                <j-dict-select-tag
                  :disabled="formDisabled"
                  type="radio"
                  v-model="model.involveMultiple"
                  dictCode="yes_no"
                  placeholder="请选择是否涉及多方信息"/>
              </a-form-model-item>
            </a-col> -->
  
            <!--迭代11 去除是否涉及多方信息-->
            <!-- <template v-if="model.involveMultiple === 1"> -->
            <template>
              <a-divider style="top:20px;">{{ this.firstTitle }}</a-divider>
              <a-col :span="24">
                <div style="margin-bottom: 6px;margin-top: 6px">
                  <a-button @click="handleAdd4" v-if="!formDisabled" type="primary">新增</a-button>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  rowKey="id"
                  :scroll="{x:'100%'}"
                  :loading="loading"
                  :columns="columns4"
                  :pagination="false"
                  :data-source="dataSource4">
                  <span slot="action" slot-scope="text, record">
                    <template v-if="!formDisabled">
                      <a-button
                        class="ruleButton"
                        :ghost="true"
                        type="primary"
                        icon="edit"
                        @click="handleEdit4(record)"/>
                      <a-divider type="vertical"/>
                      <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete4(record.id)">
                        <a-button
                          class="ruleButton"
                          :ghost="true"
                          type="primary"
                          icon="delete"
                        />
                      </a-popconfirm>
                    </template>
                  </span>
                </a-table>
              </a-col>
  
              <a-divider style="top:20px;">{{ this.secondTitle }}</a-divider>
  
              <a-col :span="24">
                <div style="margin-bottom: 6px;margin-top: 6px">
                  <a-button @click="handleAdd3" v-if="!formDisabled" type="primary">新增</a-button>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  rowKey="id"
                  :loading="loading"
                  :columns="columns3"
                  :scroll="{x:'100%'}"
                  :pagination="false"
                  :data-source="dataSource3">
                  <span slot="action" slot-scope="text, record">
                    <template v-if="!formDisabled">
                      <a-button
                        class="ruleButton"
                        :ghost="true"
                        type="primary"
                        icon="edit"
                        @click="handleEdit3(record)"/>
                      <a-divider type="vertical"/>
                      <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete3(record.id)">
                        <a-button
                          class="ruleButton"
                          :ghost="true"
                          type="primary"
                          icon="delete"
                        />
                      </a-popconfirm>
                    </template>
                  </span>
                </a-table>
              </a-col>
            </template>
            <template v-if="model.htlx == '1'">
              <a-divider style="top:20px;">任务信息</a-divider>
  
              <a-col :span="24">
                <div style="margin-bottom: 6px;margin-top: 6px">
                  <a-button @click="handleAdd2" v-if="!formDisabled" type="primary">新增</a-button>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  rowKey="id"
                  :scroll="{x:'100%'}"
                  :loading="loading"
                  :columns="columns2"
                  :pagination="false"
                  :data-source="dataSource2">
                  <span slot="action" slot-scope="text, record">
                    <template v-if="!formDisabled">
                      <a-button
                        class="ruleButton"
                        :ghost="true"
                        type="primary"
                        icon="edit"
                        @click="handleEdit2(record)"/>
                      <a-divider type="vertical"/>
                      <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete2(record.id)">
                        <a-button
                          class="ruleButton"
                          :ghost="true"
                          type="primary"
                          icon="delete"
                        />
                      </a-popconfirm>
                    </template>
                  </span>
                </a-table>
              </a-col>
            </template>
            <!-- <a-divider style="top:20px;">收付款计划</a-divider>
  
            <a-col :span="24">
              <div style="margin-bottom: 6px;margin-top: 6px">
                <a-button @click="handleAdd" v-if="!formDisabled" type="primary">新增</a-button>
              </div>
              <a-table
                ref="table"
                size="middle"
                rowKey="id"
                bordered
                :scroll="{x:scrollXOther}"
                :components="draggableComponentOther"
                :loading="loading"
                :columns="columns"
                :pagination="false"
                :data-source="dataSource">
                <span slot="action" slot-scope="text, record">
                  <template v-if="!formDisabled">
                    <a-button
                      class="ruleButton"
                      :ghost="true"
                      type="primary"
                      icon="edit"
                      @click="handleEdit(record)"/>
                    <a-divider type="vertical"/>
                    <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                      <a-button
                        class="ruleButton"
                        :ghost="true"
                        type="primary"
                        icon="delete"
                      />
                    </a-popconfirm>
                  </template>
                  <template v-if="formDisabled && model.htlx == '1'">
                    <a @click="handlePlanDetail(record)">查看</a>
                  </template>
                </span>
  
              </a-table>
            </a-col> -->
  
            <a-col :span="24">
              <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bz">
                <a-textarea :disabled="formDisabled" v-model="model.bz" rows="4" placeholder="请输入备注"/>
              </a-form-model-item>
            </a-col>
  
            <a-col :span="24">
              <a-form-model-item label="邮寄信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yjxx">
                <a-textarea :disabled="formDisabled" v-model="model.yjxx" rows="4" placeholder="请输入邮寄信息"/>
              </a-form-model-item>
            </a-col>
            <a-col :span="24" v-if="model.sfyz == 1">
              <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="signFile">
                <template v-slot:label>
                  <span >用印文件</span><span style="color: #faad14;font-weight: 600">（请上传只需盖章的用印文件！）</span>
                </template>
                <j-upload
                  v-if="!formDisabled"
                  :disabled="formDisabled"
                  v-model="model.signFile"
                  :multiple="false"
                  fileType="file"
                  :fillSize="50"
                  fileFormat=".pdf, .PDF, .doc, .docx"
                  fileFormatText="请上传word与pdf格式的文件！"
                  :isSingle="true"
                ></j-upload>
                <a-button v-else icon="download" :disabled="isRequesting" @click="viewFileOne(model.signFile)">文件列表</a-button>
              </a-form-model-item>
            </a-col>
            <a-col :span="24" v-if="model.htlx == '2'">
              <a-form-model-item label="合同原件扫描件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contractOrgFile">
                <a-button icon="download" :disabled="isRequesting" @click="viewFileOne(model.contractOrgFile)">文件列表</a-button>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item label="相关附件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xgfj">
                <!--<j-upload :disabled=formDisabled v-model="model.xgfj"   ></j-upload>-->
                <j-upload v-if="!formDisabled" :disabled="formDisabled" v-model="model.xgfj"></j-upload>
                <a-button v-else icon="download" :disabled="isRequesting" @click="viewFileOne(model.xgfj)">文件列表</a-button>
              </a-form-model-item>
            </a-col>
  
          </a-row>
        </a-form-model>
        <view-file-modal ref="viewFileModal"></view-file-modal>
        <erp-omc-contract-manager-plan-final-modal
          ref="itemList"
          @ok="modalFormOk"></erp-omc-contract-manager-plan-final-modal>
        <erp-omc-contract-manager-class-final-modal
          ref="itemList2"
          @ok="modalFormOk2"></erp-omc-contract-manager-class-final-modal>
        <!--迭代11委托方受托方修改-->
        <!-- <erp-omc-contract-manager-trustee-final-modal
          ref="itemList3"
          @ok="modalFormOk3"></erp-omc-contract-manager-trustee-final-modal>
        <erp-omc-contract-manager-entrust-final-modal
          :htlx="model.htlx"
          ref="itemList4"
          @ok="modalFormOk4"></erp-omc-contract-manager-entrust-final-modal> -->
        <erp-omc-contract-manager-trustee-modal
          ref="itemList3"
          @ok="modalFormOk3"></erp-omc-contract-manager-trustee-modal>
        <erp-omc-contract-manager-entrust-modal
          :htlx="model.htlx"
          ref="itemList4"
          @ok="modalFormOk4"></erp-omc-contract-manager-entrust-modal>
      </j-form-container>
      <!-- 项目详情开始 -->
      <erp-project-report-modal ref="reportForm"></erp-project-report-modal>
  
      <ErpPurchaseCalibrationBillPenetrate ref="purchaseCalibrationBillPenetrate" ></ErpPurchaseCalibrationBillPenetrate>
      <erp-omc-contract-manager-plan-modal
        :htlx="model.htlx"
        :projectId="model.xmmc"
        :lx="model.lx"
        ref="contractManagerPlanModal"
      ></erp-omc-contract-manager-plan-modal>
      <ErpPurchaseApplyFormPenetrate ref="purchaseApplyFormPenetrate" ></ErpPurchaseApplyFormPenetrate>
      <ErpPurchaseApplyInvitationPenetrate ref="purchaseInvitationFormPenetrate" ></ErpPurchaseApplyInvitationPenetrate>
    </a-spin>
  </template>
  
  <script>
  
  import { getAction, httpAction } from '@/api/manage'
  import SelectProjectInput from '@/views/scy/components/SelectProjectInput'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
  import SelectContractInput from '@/views/scy/components/SelectContractInput'
  import { convertCurrency } from '@/utils/MoneyConvert'
  import ErpOmcContractManagerPlanFinalModal from '../modules/ErpOmcContractManagerPlanFinalModal'
  import ErpOmcContractManagerClassFinalModal from '../modules/ErpOmcContractManagerClassFinalModal'
  import ErpOmcContractManagerTrusteeModal from '../modules/ErpOmcContractManagerTrusteeModal'
  import ErpOmcContractManagerEntrustModal from '../modules/ErpOmcContractManagerEntrustModal'
  import { filterMultiDictText, initDictOptions, filterDictTextByCache } from '@/components/dict/JDictSelectUtil'
  // import { viewFile } from '@/utils/util'
  import ViewFileModal from '@/views/scy/components/ViewFileModal'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectTaskFileInput from '@/views/scy/components/SelectTaskFileInput'; //  任务编号
  
  import SelectContractManagerInput from '@/views/scy/components/SelectContractManagerInput'
  import SelectPurchaseCalibrationInput from '@/views/scy/components/SelectPurchaseCalibrationInput'
  import ErpProjectReportModal from '@/views/erp/report/project/modules/ErpProjectReportModal'
  import SelectPurchaseApplyFormContractInput from '@/views/scy/components/SelectPurchaseApplyFormContractInput'
  import SelectPurchasingRequisitionInput from '@/views/scy/components/SelectPurchasingRequisitionInput'
  import ErpPurchaseCalibrationBillPenetrate from '@/views/scy/penetrate/ErpPurchaseCalibrationBillPenetrate'
  import ErpPurchaseApplyFormPenetrate from '@/views/scy/penetrate/ErpPurchaseApplyFormPenetrate'
  import ErpPurchaseApplyInvitationPenetrate from '@/views/scy/penetrate/ErpPurchaseApplyInvitationPenetrate'
  import ErpOmcContractManagerPlanModal from '../modules/ErpOmcContractManagerPlanModal'
  import { DragResizable } from '@/mixins/DragResizable'
  
  export default {
    name: 'ErpOmcContractManagerDetailForm',
    mixins: [DragResizable],
    components: {
      ErpOmcContractManagerPlanModal,
      SelectTaskFileInput,
      SelectPurchaseApplyFormContractInput,
      ErpProjectReportModal,
      SelectPurchaseCalibrationInput,
      SelectContractManagerInput,
      SelectProjectInput,
      SelectTeamInput,
      SelectUserByDep,
      SelectCustomerInput,
      SelectContractInput,
      ViewFileModal,
      ErpOmcContractManagerPlanFinalModal,
      ErpOmcContractManagerClassFinalModal,
      ErpOmcContractManagerTrusteeModal,
      ErpOmcContractManagerEntrustModal,
      SelectCompanyInput,
      ErpPurchaseCalibrationBillPenetrate,
      ErpPurchaseApplyFormPenetrate,
      ErpPurchaseApplyInvitationPenetrate,
      SelectPurchasingRequisitionInput
    },
    props: {
      // 表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      files: {
        type: Boolean,
        default: false
      }
    },
    data() {
      return {
        model: {},
        labelCol: {},
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 }
        },
        isRequesting:false,
        confirmLoading: false,
        validatorRules: {},
        columns: [
          {
            title: '款项名称',
            align: 'center',
            dataIndex: 'kxmc',
            width: 188,
            ellipsis: true
          },
          {
            title: '金额(元)',
            align: 'center',
            dataIndex: 'je',
            width: 188,
            ellipsis: true
          },
          {
            title: '款项日期',
            align: 'center',
            dataIndex: 'kxrq',
            width: 188,
            ellipsis: true
          },
          {
            title: '款项节点说明',
            align: 'center',
            dataIndex: 'kxjdsm',
            width: 188,
            ellipsis: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            width: 150,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        columns2: [
          {
            title: '任务档案编号',
            align: 'center',
            dataIndex: 'billNo',
            ellipsis: true
          },
          {
            title: '业务编码',
            align: 'center',
            ellipsis: true,
            dataIndex: 'ywfl',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['ywfl'], text + '')
              }
            }
          },
          {
            title: '业务名称',
            align: 'center',
            ellipsis: true,
            dataIndex: 'ywmc'
          },
          {
            title: '合同占比(%)',
            align: 'center',
            ellipsis: true,
            dataIndex: 'htzb'
          },
          {
            title: '分配合同额（元）',
            align: 'center',
            ellipsis: true,
            dataIndex: 'fphte'
          },
          {
            title: '切割合同额（元）',
            align: 'center',
            ellipsis: true,
            dataIndex: 'cutContractAmount'
          },
          {
            title: '生产团队',
            align: 'center',
            ellipsis: true,
            dataIndex: 'sctd',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['sctd'], text + '')
              }
            }
          },
          {
            title: '团队负责人',
            align: 'center',
            ellipsis: true,
            dataIndex: 'tdfzr',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['tdfzr'], text + '')
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            width: 160,
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        columns3: [
          {
            title: '名称',
            align: 'center',
             ellipsis: true,
            dataIndex: 'gsdaId_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        columns4: [
          {
            title: '名称',
            align: 'center',
            dataIndex: 'khdaId',
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(this.dictOptions['khda'], text + '')
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'
            }
          }
        ],
        url: {
          queryProjectReportById: '/api/erp/project/report/erpProjectReport/queryById',
          add: '/api/erp/omc/contractmanager/erpOmcContractManagerFinal/add',
          edit: '/api/erp/omc/contractmanager/erpOmcContractManagerFinal/edit',
          queryById: '/api/erp/omc/contractmanager/erpOmcContractManagerFinal/queryById',
  
          queryPlanList: '/api/erp/omc/contractmanager/erpOmcContractManagerPlanFinal/listAll',
          queryClassList2: '/api/erp/omc/project/erpOmcProjectTask/list',
          queryEntrustList: '/api/erp/omc/contractmanager/erpOmcContractManagerEntrustFinal/listAll',
          queryTrusteeList: '/api/erp/omc/contractmanager/erpOmcContractManagerTrusteeFinal/listAll',
          // 获取定标结果确认单信息
          queryCalibrationById: '/api/erp/purchase/procurement/erpPurchaseCalibration/queryById',
          // 获取采购申请单信息
          queryPurchaseApplyById: '/api/erp/purchase/procurement/erpPurchaseApplyForm/queryById',
          // 获取招标采购单信息
          queryInvitationById: '/api/erp/purchase/procurement/erpPurchaseApplyInvitation/queryById',
          queryClassList3: '/api/erp/omc/project/erpOmcProjectTask/listContractFinalTaskByProjectId'
  
        },
        createTime: [], // 服务期限
        dataSource: [], // 收付款计划数据源
        dataSource2: [], // 任务信息
        dataSource3: [], // 受托方信息
        dataSource4: [], // 委托方信息
        // 迭代11 委托方改为委托方(合同甲方)，受托方改为受托方（合同乙方）
        firstTitle: '委托方(合同甲方)信息',
        secondTitle: '受托方(合同乙方)信息',
        glhtFlag: false,
        dictOptions: {},
        cust_lxr: 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=0',
        loading: false
      }
    },
    computed: {
      formDisabled() {
        return this.disabled
      },
      isUseChapter() {
      if (this.model.sfyz && this.model.sfyz == 1) {
          return true
        } else {
          return false
        }
      }
    },
    created() {
      // 备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
      this.initDictConfig();
      this.otherKey = 'columns'
      // this.columnswidth = this.columns.map(val => {
      //   return val.width
      // })
    },
    methods: {

      async viewFileOne(text) {
      if (!text) {
        this.$message.warning('无可下载文件')
        return
      }
      try {
        this.isRequesting = true;
        await this.$refs.viewFileModal.show(text);
        this.isRequesting = false;
        } catch (error) {
        } finally {
          // 无论成功或失败，最后解锁按钮
          this.isRequesting = false;
        }

    },
       
      changeVal(val){
        this.$set(this.model, 'businessCompanyId',val[0].belongCompanyId)
      },
  
      goPurchaseCalibrationDetail(record) {
        this.$refs.purchaseCalibrationBillPenetrate.initData(record.calibrationId);
        this.$refs.purchaseCalibrationBillPenetrate.visible = true;
      },
      goPurchaseApplyDetail(record) {
        this.$refs.purchaseApplyFormPenetrate.initData(record.purchaseApplyId);
        this.$refs.purchaseApplyFormPenetrate.visible = true;
      },
      goInvitationDetail(record) {
        this.$refs.purchaseInvitationFormPenetrate.initData(record.invitationId);
        this.$refs.purchaseInvitationFormPenetrate.visible = true;
      },
      initDictConfig() {
        initDictOptions('ywfx_type').then((res) => {
          if (res.success) {
            // debugger;
            this.$set(this.dictOptions, 'ywfl', res.result)
          }
        })
  
        initDictOptions('YES_OR_NO').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'yes_or_no', res.result)
          }
        })
  
        initDictOptions('erp_omc_team_manager,alias_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'sctd', res.result)
          }
        })
  
        initDictOptions('erp_employee_file,name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'tdfzr', res.result)
          }
        })
  
        initDictOptions('erp_purchase_supplier,enterprise_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'khda', res.result)
          }
        })
  
        initDictOptions('erp_company_files,file_name,id').then((res) => {
          if (res.success) {
            this.$set(this.dictOptions, 'gsda', res.result)
          }
        })
      },
      handleAdd() {
        this.$refs.itemList.add();
        this.$refs.itemList.title = '新增';
        this.$refs.itemList.disableSubmit = false;
      },
      handleEdit(record) {
        this.$refs.itemList.edit(record);
        this.$refs.itemList.title = '修改';
        this.$refs.itemList.disableSubmit = false;
        // 判断是收款合同还是付款合同
      },
      handleDelete(id) {
        for (let i = 0; i < this.dataSource.length; i++) {
          if (this.dataSource[i].id == id) {
            this.dataSource.splice(i, 1);
          }
        }
      },
      handleAdd2() {
        this.$refs.itemList2.add();
        this.$refs.itemList2.title = '新增';
        this.$refs.itemList2.disableSubmit = false;
      },
      handleEdit2(record) {
        this.$refs.itemList2.edit(record);
        this.$refs.itemList2.title = '修改';
        this.$refs.itemList2.disableSubmit = false;
      },
      handleDelete2(id) {
        for (let i = 0; i < this.dataSource2.length; i++) {
          if (this.dataSource2[i].id == id) {
            this.dataSource2.splice(i, 1);
          }
        }
      },
      handleAdd3() {
        this.$refs.itemList3.add();
        this.$refs.itemList3.title = '新增';
        this.$refs.itemList3.disableSubmit = false;
      },
      handleEdit3(record) {
        this.$refs.itemList3.edit(record);
        this.$refs.itemList3.title = '修改';
        this.$refs.itemList3.disableSubmit = false;
      },
      handleDelete3(id) {
        for (let i = 0; i < this.dataSource3.length; i++) {
          if (this.dataSource3[i].id == id) {
            this.dataSource3.splice(i, 1);
          }
        }
      },
      handleAdd4() {
        this.$refs.itemList4.add();
        this.$refs.itemList4.title = '新增';
        this.$refs.itemList4.disableSubmit = false;
      },
      handleEdit4(record) {
        this.$refs.itemList4.edit(record);
        this.$refs.itemList4.title = '修改';
        this.$refs.itemList4.disableSubmit = false;
      },
      handleDelete4(id) {
        for (let i = 0; i < this.dataSource4.length; i++) {
          if (this.dataSource4[i].id == id) {
            this.dataSource4.splice(i, 1);
          }
        }
      },
      handlePlanDetail(record) {
        // 修改时将当前的值从remain中减去
        this.editRemain = record.je;
        this.$refs.contractManagerPlanModal.edit(record);
        this.$refs.contractManagerPlanModal.title = '查看';
        this.$refs.contractManagerPlanModal.disableSubmit = true;
      },
      getProjectDetail(id) {
        const that = this
        this.$nextTick(() => {
          getAction(this.url.queryProjectReportById, { id }).then((res) => {
            if (res.success) {
              const model = res.result
              that.$refs.reportForm.getDetail(model);
              that.$refs.reportForm.title = '项目一览表';
            }
          })
        })
      },
      modalFormOk(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource.length; i++) {
          if (this.dataSource[i].id == data.id) {
            this.dataSource.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource.push(data);
        }
        this.loading = false;
      },
      modalFormOk2(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource2.length; i++) {
          if (this.dataSource2[i].id == data.id) {
            this.dataSource2.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource2.push(data);
        }
        this.loading = false;
      },
      modalFormOk3(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource3.length; i++) {
          if (this.dataSource3[i].id == data.id) {
            this.dataSource3.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource3.push(data);
        }
        this.loading = false;
      },
      modalFormOk4(data) {
        this.loading = true;
        let flag = true;
        // debugger;
        for (let i = 0; i < this.dataSource4.length; i++) {
          if (this.dataSource4[i].id == data.id) {
            this.dataSource4.splice(i, 1, data);
            flag = false;
          }
        }
        if (flag) {
          this.dataSource4.push(data);
        }
        this.loading = false;
      },
      yzdwChange() {
        this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
        this.$set(this.model, 'lxr', undefined);
        this.$set(this.model, 'lxfs', undefined);
      },
      lxrChange(val) {
        // debugger
        getAction('/api/erp/omc/customermanager/erpOmcCustomerManagerContact/queryById', { id: val }).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            // debugger;
            // this.model.lxdh = data.lxfs;
            this.$set(this.model, 'lxr', val)
            this.$set(this.model, 'lxfs', data.lxfs)
          }
        })
      },
      add() {
        this.dataSource = []
        this.dataSource2 = []
        this.dataSource3 = []
        this.dataSource4 = []
        this.modelDefault.lx = 1
        this.edit(this.modelDefault);
      },
      add2() {
        this.dataSource = []
        this.dataSource2 = []
        this.dataSource3 = []
        this.dataSource4 = []
        this.modelDefault.lx = 2
        this.edit(this.modelDefault);
      },
      handleChangeCategory(val) {
        if (val == '1') {
          this.$set(this.validatorRules, 'provisionType', [{ required: true, message: '请选择采购类型!' }]);
        } else {
          this.$set(this.model, 'provisionType', null);
          this.$delete(this.validatorRules, 'provisionType');
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
        }
      },
      handleChangeProvisionType(val) {
        if (val == '1') {
          this.$set(this.validatorRules, 'calibrationId', [{ required: true, message: '请选择定标结果确认单!' }]);
          // 清除采购申请单数据及校验
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
          // 清除招标采购申请单数据及校验
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
        } else if (val == '2') {
          this.$set(this.validatorRules, 'purchaseApplyId', [{ required: true, message: '请选择采购申请单!' }]);
          // 清除定标结果确认单数据及校验
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
          // 清除招标采购申请单数据及校验
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
        } else if (val == '3') {
          this.$set(this.validatorRules, 'invitationId', [{ required: true, message: '请选择招标采购申请单!' }]);
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
        } else {
          // 清除采购申请单数据及校验
          this.$set(this.model, 'purchaseApplyId', null);
          this.$delete(this.validatorRules, 'purchaseApplyId');
          // 清除招标采购申请单数据及校验
          this.$set(this.model, 'invitationId', null);
          this.$delete(this.validatorRules, 'invitationId');
          // 清除定标结果确认单数据及校验
          this.$set(this.model, 'calibrationId', null);
          this.$delete(this.validatorRules, 'calibrationId');
        }
      },
  
      showPlanColumn (record) {
        if (record.htlx == '2') {
          this.columns = [
            {
              title: '款项名称',
              align: 'center',
              dataIndex: 'kxmc',
              width: 188,
              ellipsis: true
            },
            {
              title: '金额(元)',
              align: 'center',
              dataIndex: 'je',
              width: 188,
              ellipsis: true
            },
            {
              title: '款项日期',
              align: 'center',
              dataIndex: 'kxrq',
              width: 188,
              ellipsis: true
            },
            {
              title: '款项节点说明',
              align: 'center',
              dataIndex: 'kxjdsm',
              width: 188,
              ellipsis: true
            }
          ]
        } else {
          this.columns = [
            {
              title: '款项名称',
              align: 'center',
              dataIndex: 'kxmc',
              width: 200,
              ellipsis: true
            },
            {
              title: '金额(元)',
              align: 'center',
              dataIndex: 'je',
              width: 200,
              ellipsis: true
            },
            {
              // 3.收付款计划列表中的款项时间改为预计款项时间，为必填
              title: '预计款项日期',
              align: 'center',
              dataIndex: 'kxrq',
              width: 200,
              ellipsis: true
            },
            {
            // 3.收付款计划列表中的款项时间改为预计款项时间，为必填
              title: '款项节点说明',
              align: 'center',
              dataIndex: 'kxjdsm',
              width: 200,
              ellipsis: true
            },
            {
              title: '款项关联任务',
              align: 'center',
              dataIndex: 'taskId_dictText',
              width: 300,
              ellipsis: true
            },
            {
              title: '应收状态',
              align: 'center',
              dataIndex: 'collectMoneyStatus',
              width: 200,
              ellipsis: true
            },
            // {
            //   title: '款项节点说明',
            //   align: 'center',
            //   dataIndex: 'kxjdsm',
            //   width: 200,
            //   ellipsis: true
            // },
            {
              title: '操作',
              dataIndex: 'action',
              align: 'center',
              width: 150,
              scopedSlots: {
                filterDropdown: 'filterDropdown',
                filterIcon: 'filterIcon',
                customRender: 'action'
              }
            }
          ]
        }
      },
      edit(record) {
        // 判断合同类型，收付款计划修改字段
        this.showPlanColumn(record)
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        // 根据ID获取定标结果确认单单号 用于穿透
        if (this.formDisabled && this.model.calibrationId) {
          getAction(this.url.queryCalibrationById, { id: this.model.calibrationId }).then(res => {
            this.$set(this.model, 'calibrationNo', res.result.purchaseBill);
          }).catch(e => {
            console.log(e)
          })
        }
        // 根据ID获取采购申请单单号 用于穿透
        if (this.formDisabled && this.model.purchaseApplyId) {
          getAction(this.url.queryPurchaseApplyById, { id: this.model.purchaseApplyId }).then(res => {
            this.$set(this.model, 'purchaseNo', res.result.purchaseBill);
          }).catch(e => {
            console.log(e)
          })
        }
        // 根据ID获取采购申请单单号 用于穿透
        if (this.formDisabled && this.model.invitationId) {
          getAction(this.url.queryInvitationById, { id: this.model.invitationId }).then(res => {
            this.$set(this.model, 'invitationNo', res.result.purchaseBill);
          }).catch(e => {
            console.log(e)
          })
        }
        if (this.contractType == '1') {
          this.$set(this.validatorRules, 'distributionMethod', [{ required: true, message: '请选择分配方式!' }])
        } else {
          this.$delete(this.validatorRules, 'distributionMethod')
        }
        this.cust_lxr = 'erp_omc_customer_manager_contact,lxr,id,del_flag=0 and main_id=\'' + this.model.yzdw + '\'';
  
        if (this.model.id) {
          if (this.model.isCategoryType) {
            this.handleChangeCategory(this.model.isCategoryType)
            if (this.model.provisionType) {
              this.handleChangeProvisionType(this.model.provisionType)
            }
          }
          // 收款计划
          getAction(this.url.queryPlanList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              // res.result数组中的planTaskList数组中拼接categoryName形成款项关联任务
              res.result.map((value, index) => {
                res.result[index].taskId_dictText = '' // 首先款项关联任务字段默认为空
                // 遍历planTaskList数组赋值给taskId_dictText
                res.result[index].taskId_dictText = value.planTaskList && value.planTaskList.length ? (value.planTaskList.map((obj) => { return obj.categoryName }).join(',')) : '';
              })
              this.dataSource = res.result.records || res.result
            }
          })
          getAction(this.url.queryClassList3, { projectId: this.model.xmmc }).then((res) => {
            let data = res || []
            this.dataSource2 = []
            if (data.length) {
              for (let i = 0; i < data.length; i++) {
                let d = {
                  'billNo': data[i].billNo,
                  'ywfl': data[i].categoryCode,
                  'ywmc': data[i].categoryName,
                  'htzb': data[i].contractRate,
                  'fphte': data[i].contractAmount,
                  'cutContractAmount': data[i].cutContractAmount,
                  'sctd': data[i].productTeam,
                  'tdfzr': data[i].teamLeader
                };
                this.dataSource2.push(d);
              }
            }
          })
          // 受托方信息
          getAction(this.url.queryTrusteeList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              // debugger;
              this.dataSource3 = res.result.records || res.result
            }
          })
  
          // 委托方信息
          getAction(this.url.queryEntrustList, { mainId: this.model.id }).then((res) => {
            if (res.success) {
              this.dataSource4 = res.result.records || res.result
            }
          })
          this.showKxxx = true;
          this.glhtFlag = this.model.glskht == 1
        }
        // 服务期限
        if (!!this.model.fwqx && !!this.model.fwqxEnd) {
          this.createTime = []
          this.createTime.push(this.model.fwqx)
          this.createTime.push(this.model.fwqxEnd)
        } else {
          this.createTime = []
        }
        this.visible = true;
        // 迭代11 委托方 受托方 修改
        if (this.model && this.model.htlx) {
          if (this.model.htlx === '1' || this.model.htlx === 1) {
            // 将受托方子modal中的是否显示付款改为false
            this.$refs.itemList3.isFk = false
            this.$refs.itemList4.isFk = true
            this.changeTitle()
          } else {
            // 将受托方子modal中的是否显示付款改为true
            this.$refs.itemList3.isFk = true
            this.$refs.itemList4.isFk = false
            this.changeTitle(1)
          }
        } else {
          // 将受托方子modal中的是否显示付款改为false
          this.$refs.itemList3.isFk = false
          this.$refs.itemList4.isFk = true
          this.changeTitle()
        }
        // 详情页去除表头中的操作
        if (this.formDisabled) {
          this.columns3.pop()
          this.columns4.pop()
        }
        // this[this.otherKey].forEach((val,index) => {
        //   val.width = this[this.otherKey+'width'][index]
        // })
      },
      submitForm() {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if (!this.model.id) {
              httpurl += this.url.add;
              method = 'post';
            } else {
              httpurl += this.url.edit;
              method = 'put';
            }
            httpAction(httpurl, this.model, method).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.$emit('ok');
              } else {
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
        })
      },
      convertMoney1() {
        let money = this.model.skhte
        this.$set(this.model, 'skhtedx', convertCurrency(money))
      },
      convertMoney2() {
        let money = this.model.bchte
        this.$set(this.model, 'bchtedx', convertCurrency(money))
      },
      xmmcChange(val) {
        getAction('/api/erp/omc/project/erpOmcProject/queryById', { id: val }).then((res) => {
          if (res.success) {
            let data = res.result.records || res.result
            // debugger;
            // this.model.lxdh = data.lxfs;
            this.$set(this.model, 'xmbh', data.projectNo) // 项目编号
            this.$set(this.model, 'jytd', data.teamName) // 经营团队
            this.$set(this.model, 'businessCompanyId', data.businessCompanyId) // 经营团队
            this.$set(this.model, 'yjgsnd', data.year) // 业绩归属年度
            this.$set(this.model, 'qddw', data.signUnit) // 签定单位
            this.$set(this.model, 'xmcjr', data.undertaker) // 项目承接人
            this.$set(this.model, 'yzdw', data.ownerUnit) // 业主单位
            this.$set(this.model, 'lxr', data.contacts) // 联系人
            this.$set(this.model, 'lxfs', data.contactTel) // 联系方式
  
            this.yzdwChange()
  
            // 任务信息
            getAction(this.url.queryClassList2, { pageNo: 1, pageSize: 999, projectId: data.id }).then((res) => {
              if (res.success) {
                let data = res.result.records || res.result
                // debugger;
                for (let i = 0; i < data.length; i++) {
                  let d = {
                    'billNo': data[i].billNo,
                    'ywfl': data[i].categoryCode,
                    'ywmc': data[i].categoryName,
                    'htzb': data[i].contractRate,
                    'fphte': data[i].contractAmount,
                    'cutContractAmount': data[i].cutContractAmount,
                    'sctd': data[i].productTeam,
                    'tdfzr': data[i].teamLeader
                  };
                  this.dataSource2.push(d);
                }
              }
            })
          }
        })
      },
      htlxChange(val) {
        this.$set(this.model, 'htlx', val)
        if (val) {
          let url;
          if (val === '1') {
            // 合同类型为收款合同，需要做特殊处理
            // updated  by wuzx at 2021/12/28 调整为立项底表查询,不带bpmStatus
            // 修改前:  url = '/api/erp/omc/project/erpOmcProjectApply/list2?bpmStatus=3&isSkht=true";
            // 修改后:
            url = '/api/erp/omc/project/erpOmcProject/list2?isSkht=true';
          } else {
            // 合同类型为收款合同，需要做特殊处理
            // updated by wuzx at 2021/12/28 调整为立项底表查询,不带bpmStatus
            // 修改前: url = '/api/erp/omc/project/erpOmcProjectApply/list2?bpmStatus=3&isSkht=false";
            // 修改后:
            url = '/api/erp/omc/project/erpOmcProject/list2?isSkht=false';
          }
          this.$refs.projectModel.loadData(url);
        }
      },
      glskhtChange(val) {
        // debugger;
        this.$set(this.model, 'glskht', val)
        if (val) {
          if (val === '1') {
            this.glhtFlag = true;
          } else {
            this.glhtFlag = false;
          }
        }
      },
      // 服务期限开始时间 结束时间
      createTimeChange(date, dateString) {
        this.$set(this.model, 'fwqx', dateString[0] + ' 00:00:00')
        this.$set(this.model, 'fwqxEnd', dateString[1] + ' 23:59:59')
      },
      changeTitle(args) {
         if (args === 1) { // 收款合同类型时
          this.firstTitle = '受托方(合同乙方)信息'
          this.secondTitle = '委托方(合同甲方)信息'
            // 修改列表表头
            this.$set(this, 'columns4', [
              {
                title: '名称',
                align: 'center',
                dataIndex: 'khdaId',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterMultiDictText(this.dictOptions['khda'], text + '')
                  }
                }
              },
              // {
              //   title: '是否为收款单位',
              //   align: 'center',
              //   dataIndex: 'isSk',
              //   customRender: (text) => {
              //     if (!text) {
              //       return ''
              //     } else {
              //       return filterMultiDictText(this.dictOptions['yes_or_no'], text + '')
              //     }
              //   }
              // },
              {
                title: '对方是否电子签章',
                align: 'center',
                dataIndex: 'isSignSeal',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterDictTextByCache('yes_no', text)
                  }
                }
              },
              {
                title: '对方盖章人',
                align: 'center',
                dataIndex: 'psnName'
              },
              {
                title: '联系方式',
                align: 'center',
                dataIndex: 'psnMobile'
              },
              {
                title: '操作',
                dataIndex: 'action',
                align: 'center',
                scopedSlots: {
                  filterDropdown: 'filterDropdown',
                  filterIcon: 'filterIcon',
                  customRender: 'action'
                }
              }
              ])
              this.$set(this, 'columns3', [
              {
                title: '名称',
                align: 'center',
                dataIndex: 'gsdaId',
                customRender: (text) => {
                  if (!text) {
                    return ''
                  } else {
                    return filterMultiDictText(this.dictOptions['gsda'], text + '')
                  }
                }
              },
              // {
              //   title: '是否为付款单位',
              //   align: 'center',
              //   dataIndex: 'isFk',
              //   customRender: (text) => {
              //     if (!text) {
              //       return ''
              //     } else {
              //       return filterMultiDictText(this.dictOptions['yes_or_no'], text + '')
              //     }
              //   }
              // },
              {
                title: '我方经办人',
                align: 'center',
                dataIndex: 'psnName'
              },
              {
                title: '联系方式',
                align: 'center',
                dataIndex: 'psnMobile'
              },
              {
                title: '操作',
                dataIndex: 'action',
                align: 'center',
                scopedSlots: {
                  filterDropdown: 'filterDropdown',
                  filterIcon: 'filterIcon',
                  customRender: 'action'
                }
              }
            ])
         } else { // 付款合同类型时
          this.firstTitle = '委托方(合同甲方)信息'
          this.secondTitle = '受托方(合同乙方)信息'
          // 修改列表表头
          this.$set(this, 'columns4', [
            {
              title: '名称',
              align: 'center',
              dataIndex: 'khdaId',
              customRender: (text) => {
                if (!text) {
                  return ''
                } else {
                  return filterMultiDictText(this.dictOptions['khda'], text + '')
                }
              }
            },
            // {
            //   title: '是否为付款款单位',
            //   align: 'center',
            //   dataIndex: 'isFk',
            //   customRender: (text) => {
            //     if (!text) {
            //       return ''
            //     } else {
            //       return filterMultiDictText(this.dictOptions['yes_or_no'], text + '')
            //     }
            //   }
            // },
            {
              title: '对方是否电子签章',
              align: 'center',
              dataIndex: 'isSignSeal',
              customRender: (text) => {
                if (!text) {
                  return ''
                } else {
                  return filterDictTextByCache('yes_no', text)
                }
              }
            },
            {
              title: '对方盖章人',
              align: 'center',
              dataIndex: 'psnName'
            },
            {
              title: '联系方式',
              align: 'center',
              dataIndex: 'psnMobile'
            },
            {
              title: '操作',
              dataIndex: 'action',
              align: 'center',
              scopedSlots: {
                filterDropdown: 'filterDropdown',
                filterIcon: 'filterIcon',
                customRender: 'action'
              }
            }
            ])
            this.$set(this, 'columns3', [
            {
              title: '名称',
              align: 'center',
              dataIndex: 'gsdaId',
              customRender: (text) => {
                if (!text) {
                  return ''
                } else {
                  return filterMultiDictText(this.dictOptions['gsda'], text + '')
                }
              }
            },
            // {
            //   title: '是否为收款单位',
            //   align: 'center',
            //   dataIndex: 'isSk',
            //   customRender: (text) => {
            //     if (!text) {
            //       return ''
            //     } else {
            //       return filterMultiDictText(this.dictOptions['yes_or_no'], text + '')
            //     }
            //   }
            // },
            {
              title: '我方经办人',
              align: 'center',
              dataIndex: 'psnName'
            },
            {
              title: '联系方式',
              align: 'center',
              dataIndex: 'psnMobile'
            },
            {
              title: '操作',
              dataIndex: 'action',
              align: 'center',
              scopedSlots: {
                filterDropdown: 'filterDropdown',
                filterIcon: 'filterIcon',
                customRender: 'action'
              }
            }
          ])
        }
      }
    }
  }
  </script>
  